package com.fr.report.core.util;

import com.fr.report.CellElement;
import java.util.Comparator;

public class CellElementComparator
  implements Comparator
{
  private boolean rowFirst = true;
  private static CellElementComparator COLUMN_FIRST = new CellElementComparator(false);
  private static CellElementComparator ROW_FIRST = new CellElementComparator(true);

  public static CellElementComparator getColumnFirstComparator()
  {
    return COLUMN_FIRST;
  }

  public static CellElementComparator getRowFirstComparator()
  {
    return ROW_FIRST;
  }

  private CellElementComparator(boolean paramBoolean)
  {
    this.rowFirst = paramBoolean;
  }

  public int compare(Object paramObject1, Object paramObject2)
  {
    if ((!(paramObject1 instanceof CellElement)) || (!(paramObject2 instanceof CellElement)))
      return 0;
    CellElement localCellElement1 = (CellElement)paramObject1;
    CellElement localCellElement2 = (CellElement)paramObject2;
    if (this.rowFirst)
    {
      if (localCellElement1.getRow() < localCellElement2.getRow())
        return -1;
      if (localCellElement1.getRow() > localCellElement2.getRow())
        return 1;
      if (localCellElement1.getColumn() < localCellElement2.getColumn())
        return -1;
      if (localCellElement1.getColumn() <= localCellElement2.getColumn())
        break label178;
      return 1;
    }
    if (localCellElement1.getColumn() < localCellElement2.getColumn())
      return -1;
    if (localCellElement1.getColumn() > localCellElement2.getColumn())
      return 1;
    if (localCellElement1.getRow() < localCellElement2.getRow())
      return -1;
    if (localCellElement1.getRow() > localCellElement2.getRow())
      return 1;
    label178: return 0;
  }
}